/**
 * 
 */
package com.hjx.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hjx.dao.AssetMapper;
import com.hjx.model.Asset;
import com.hjx.model.AssetCriteria;
import com.hjx.model.Page;
import com.hjx.service.IAssetService;

/**
 * @author huangjixin
 * 
 */
@Service(value = "assetService")
@RemotingDestination(value = "assetService",channels= {"my-amf","my-secure-amf"})
@Transactional
public class AssetServiceImpl extends AbstractGenericService<Asset, Integer> implements
		IAssetService {

	@Autowired
	private AssetMapper assetMapper;
	
	@Override
	public List<Asset> selectAll() {
		List<Asset> list = assetMapper.selectByExample(new AssetCriteria());
		return list;
	}

	@Override
	public Page selectByPage(Page page) {
		AssetCriteria userCriteria = new AssetCriteria();
		userCriteria.setStart(page.getStart());
		userCriteria.setLimit(page.getLimit());
		int count = assetMapper.countByExample(new AssetCriteria());
		List<Asset> list = assetMapper.selectByExample(userCriteria);
		page.setCount(count);
		page.setList(list);
		
		return page;
	}
	
	@Override
	public int deleteByPrimaryKey(Integer id) {
		int i = assetMapper.deleteByPrimaryKey(id);
		return i;
	}

	@Override
	public int insert(Asset record) {
		super.insert(record);
		int i = assetMapper.insert(record);
		return i;
	}

	@Override
	public int insertSelective(Asset record) {
		super.insertSelective(record);
		int i = assetMapper.insertSelective(record);
		return i;
	}

	@Override
	public Asset selectByPrimaryKey(Integer id) {
		Asset user = assetMapper.selectByPrimaryKey(id);
		return user;
	}

	@Override
	public int updateByPrimaryKeySelective(Asset record) {
		int i = assetMapper.updateByPrimaryKeySelective(record);
		return i;
	}

	@Override
	public int updateByPrimaryKey(Asset record) {
		int i = assetMapper.updateByPrimaryKey(record);
		return i;
	}

}
